﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LinkedList
{
    public class LinkedlistStack<E> : Stack<E>
    {

        private Linkedlist<E> list;

        public LinkedlistStack()
        {
            list = new Linkedlist<E>();
        }


        public int getsize()
        {
            return list.getSize();
        }


        public bool isEmpty()
        {
            return list.isEmpty();
        }


        public void push(E e)
        {
            list.addFirst(e);
        }


        public E pop()
        {
            return list.removeFirst();
        }


        public E peek()
        {
            return list.getFirst();
        }

        public override string ToString()
        {
            StringBuilder res = new StringBuilder();
            res.Append("Stack: top ");
            res.Append(list);
            return res.ToString();
        }
    }
}
